<?  $sess = new Zend_Session_Namespace(CLU_NS);?>
<div class="box white_bg">

<h1> Users List</h1>


<script type="text/javascript">
$(function() {
    $("a.user-delete").click(function(e){
         parent_row = $(this).parent().parent();
         id = parent_row.attr('id');
         $.getJSON("/<?=$sess->viewLang?>/user/account/delete-user", {'id': id},
            function(json) {
               alert(json.success);
               if (json.success)
                    parent_row.css("background-color", 'red').fadeOut(1000);
               else
                    alert(json.message);
            });
         return false;
    });
    

    $("table.roleList tr:nth-child(odd)").addClass("striped");

    $("tr").mouseover(function(e){
                        jQuery(this).find(".tr-action").show();
                }).mouseout(function(){
                        jQuery(this).find(".tr-action").hide();
                });
});

</script>

  
<table class="roleList" border="1">
<tr style="background-color:#EEEEEE; height:20px">
<td style="text-align:center"><b style="font-size:16px;color:red">id</b></td>
<td style="text-align:center"><b style="font-size:16px;color:red">Name</b></td>
<td style="text-align:center"><b style="font-size:16px;color:red">Mail</b></td>
<td style="text-align:center"><b style="font-size:16px;color:red">Status</b></td>
<td style="text-align:center"><b style="font-size:16px;color:red">Roles</b></td>
<td style="text-align:center"><b style="font-size:16px;color:red">Operator</b></td>
</tr>
<?if(isset($this->viewParams['userList'])) :?>
	<?foreach ($this->viewParams['userList'] as $user) :?>
		  <tr id="<?=$user['id']?>" class="user-row">
		    <td width="5%"><?=$user['id'] ?></td>
		    <td width="10%"> <b><a href="/<?=$sess->viewLang?>/user/account/view?id=<?=$user['id'] ?>"><?= $user['name']?></a></b></td>
		    <td width="15%"> <b><?= $user['mail']?></b></td>
		    <td width="20%"> <b>
	    		<?if($user['status'] == 0) :?>
					<?=t(486)?>
				<?elseif($user['status'] == 1) :?>
					<?=t(487)?>
				<?elseif($user['status'] == 2) :?>
					<?=t(488)?>
				<?elseif($user['status'] == 3) :?>
					<?=t(489)?>
				<?elseif($user['status'] == 4) :?>
					<?=t(490)?>
				<?endif?></b></td>
		    <td><?=$this->viewParams['userRoles'][$user['id']] ?></td>
		    
		    <td width="25%">
			    <a href="/<?=$sess->viewLang?>/user/account/change-pass?id=<?=$user['id']?>">Pwd</a> |
			    <a href="/<?=$sess->viewLang?>/user/admin/edit?id=<?=$user['id']?>">edit</a> |
		    	<?if(strpos($sess->userPermissions, 'administer everything')) :?>
				    <a href="javascript:void()" class="user-delete">delete</a>
				    <a href="/<?=$sess->viewLang?>/user/admin/assign-roles?uid=<?=$user['id']?>&uname=<?=$user['name']?>">roles</a> |
			    <?endif?> 
			    <a href="/<?=$sess->viewLang?>/user/account/activate-role-for-user-company?id=<?=$user['id']?>&upgrade_to=<?if(isset($user['upgrade_to'])) :?><?=$user['upgrade_to']?><?endif?>&type=<?=$user['type']?>&status=<?=$user['status']?>">Activate</a> | 
      			<a href="/<?=$sess->viewLang?>/user/account/activate-role-for-user-company?id=<?=$user['id']?>&type=unactivate"><?=t(486)?></a>
			</td>
		  </tr>
	<?endforeach?>
<?endif?>
</table>
<br />
<div style="width:100%;float: right" id = "paging">
<?if(isset($this->viewParams['paginator'])) :?>
<?= $this->paginationControl($this->viewParams['paginator'], 'Sliding', '/modules/user/views/scripts/commonTheme/commonLang/common/my_pagination_control.phtml'); ?>
<?endif?>
</div>
<br/>


</div>